<?php

declare(strict_types=1);

namespace app\shop\model\activity;

use sheep\model\Common;
use app\shop\model\order\Order;
use app\shop\model\order\OrderItem;
use app\shop\model\goods\Goods;

class GrouponLog extends Common
{


    protected $name = 'shop_activity_groupon_log';


    public function getNicknameAttr($value, $data)
    {
        $value = $value ?: ($data['nickname'] ?? '');
        return $value ? string_hide($value, 2) : $value;
    }


    public function order() 
    {
        return $this->belongsTo(Order::class, 'order_id');
    }


    public function groupon()
    {
        return $this->belongsTo(Groupon::class, 'groupon_id');
    }

    public function goods()
    {
        return $this->belongsTo(Goods::class, 'goods_id');
    }


    public function orderItem()
    {
        return $this->hasOne(OrderItem::class, 'order_id', 'order_id');
    }
}
